home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / BODI / DRAW.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  45.8 KB  |  1,725 lines

  1. /**************************************************************************/
  2. /*  FILE:  DRAW.C        PROGRAM TITLE: DeskSET II Alpha Version   */
  3. /*  Date Created: 01/11/88                          */ 
  4. /*  Last Modified: 11/16/88                          */
  5. /*                                      */
  6. /*  Description: POLYGON DRAW ROUTINES                      */
  7. /*  Routines:    o   nada()        - Null Function              */
  8. /*              o   poly_draw()        - Draw and Store Polygon      */
  9. /*        o   ellipse_draw()    - Draw and Store Ellipse      */
  10. /*        o   circle_draw()    - Draw and Store Circle          */
  11. /*        o   box_draw()        - Draw and Store Box          */
  12. /*        o   redraw_ellipse()    - Redraw Ellipses and Circles     */
  13. /*        o   redraw_polygon()    - Redraw Polygon          */
  14. /*        o   do_scanner()    - perform rectangle scanning      */
  15. /*        o   do_outline()    - box around selected regions     */
  16. /*        o   do_box()        - draw a filled box...           */
  17. /*        o   write_black()    - set device to write black      */
  18. /*        o   write_white()    - set device to write white      */
  19. /*        o   write_atari()    - set device to write atari logo  */
  20. /*        o   handle_atari()    - write white/atari for images    */
  21. /*        o   handle_write()    - write white/black/pattern      */
  22. /**************************************************************************/
  23.  
  24. /**************************************************************************/
  25. /* HISTORY                                  */
  26. /*                                      */
  27. /* 11/07/89  - Replace all calls to scale_v() with scaler()          */
  28. /*         - circle_draw() - replace scale_v() with scaler()          */
  29. /**************************************************************************/
  30.  
  31. /**************************************************************************/
  32. /* INCLUDE FILES                              */
  33. /**************************************************************************/
  34. #include "deskset2.h"
  35. #include <obdefs.h>
  36. #include "gemdefs.h"
  37. #include "define.h"
  38. #include "dbase.h"
  39.  
  40. /**************************************************************************/
  41. /* DEFINES                                  */
  42. /**************************************************************************/
  43. #define max(x,y) (((x) > (y)) ? (x) : (y))
  44. #define min(x,y) (((x) < (y)) ? (x) : (y))
  45.  
  46.  
  47. /**************************************************************************/
  48. /* EXTERNALS                                  */
  49. /**************************************************************************/
  50. extern int phys_handle;                /* Handles, just in case  */
  51. extern int shandle;                /* screen handle          */
  52. extern int phandle;                /* printer handle         */
  53. extern int mhandle;                /* preview buffer handle  */
  54. extern int xor_handle;                /* second screen handle   */
  55. extern int print_flag;                /* printing flag...       */
  56.  
  57. extern int ptsarray[];                /* data struct interface  */
  58. extern int curr_page;                /* current page...        */
  59.  
  60. extern int prev_handle;                /* preview window handle  */
  61.  
  62. extern int pagew,pageh;                /* current width and ht.. */
  63.                         /* in pixels              */
  64. extern mode_flag;                /* solid/text mode        */
  65. extern write_flag;                /* write white/black flag */
  66.  
  67. extern unsigned long page_ptr;            /* preview buffer pointer */
  68. extern unsigned long pagesc;            /* ditto...          */
  69.  
  70. extern unsigned long scanptr;            /* scan buffer pointer    */
  71. extern unsigned long scanesc;            /* ditto...          */
  72.  
  73. extern int scan_xres;                /* scan buffer x res...   */
  74. extern int scan_yres;                /* scan buffer y res...   */
  75.  
  76. extern int mxres,myres;                /* preview buffer x,y res */
  77. extern int rect_in_mu[];            /* rectangle in MU...      */
  78.  
  79. extern int ptsin[];                /* PTSIN[] array          */
  80.  
  81. extern char *tmpptr;                /* CS 2/6/88          */
  82. extern char *endptr;                
  83. extern char *dotext();
  84. extern struct slvll    *getslvptr();        /* Return regions slave ptr */
  85. extern int view_size;                /* current view size      */
  86. extern int axdpi[];                /* xdpi and ydpi arrays   */
  87. extern int aydpi[];
  88. extern int zdevice;
  89.  
  90. extern int pxyarray[];                /* Some global arrays     */
  91. extern int pxy[];                /* ditto          */
  92. extern int status;                /* used by GDv_updwk()    */
  93. extern int dummy;                /* dummy variable filler  */
  94. extern int dumb;
  95.  
  96. extern int cur_scale;                /* current scale...       */
  97. extern int cur_primitive;            /* current graphic        */
  98.                         /* primitive - RCS numbers*/
  99. extern char fbuffer[];                /* file name buffer       */
  100. extern int cur_pic_type;            /* NEO, IMG, GEM      */
  101. extern int graph_flag;                /* graphic region? 1-TRUE */
  102. extern unsigned long gl_grregion_ptr;        /* Ptr to graphic region  */
  103. extern struct txtattr gltxtattr;        /* Global text attr struct*/
  104. extern int glgrattr[];                /* Global graphic attr    */
  105. extern struct textobj gltext;
  106.  
  107. extern FDB laser_MFDB;
  108. extern FDB page_MFDB;
  109.  
  110. extern char cpabt;
  111. extern int opcode;
  112. extern int maxpat;
  113.  
  114. extern REGION *curregion;
  115. extern long getf_scaninfo();
  116. extern long getn_scaninfo();
  117.  
  118. extern int hpage_size;
  119. extern int vpage_size;
  120. extern PNUMBER pnum;
  121.  
  122. extern unsigned char *buf_start;
  123. extern unsigned char *buf_end;
  124. extern unsigned char *free_start;
  125. extern unsigned char *current_char;
  126. extern int tmplate_flag;
  127.  
  128. extern int active_prim;
  129.  
  130. /**************************************************************************/
  131. /* GLOBAL VARIABLES                              */
  132. /**************************************************************************/
  133. int (*funcs)();                    /* current drawing funct. */
  134. int SX,SY;                    /* start scan here...     */
  135. int flag;                    /* variable flag...       */
  136. int SH;                        /* Line spacing for mask  */
  137.  
  138. typedef struct sfdb                /* Scan buffer structure  */
  139.      {
  140.         long BASE;                /* Base address of form   */
  141.         int FORM_WD;                /* form width in bytes.   */
  142.         int FORM_HT;                /* form height (pixels)   */
  143.         int B_XMIN;                /* upper left x          */
  144.         int B_YMIN;                /* upper left y       */
  145.         int B_XMAX;                /* lower left x           */
  146.         int B_YMAX;                /* lower left y           */
  147.      }  SFDB;                    /* name of structure      */
  148.  
  149. SFDB jim_ptr;                    /* pointer to structure   */
  150.  
  151. typedef    struct    mfdb
  152.     {
  153.     long    data;
  154.     int    width;
  155.     int    height;
  156.     int    wwidth;
  157.     int    format;
  158.     int    planes;
  159.     int    res1;
  160.     int    res2;
  161.     int    res3;
  162.     }MFDB;
  163.  
  164. MFDB txtmfdb;                    /* TEXT mfdb CS 2/6/88    */
  165. int mboxx2[254];
  166. int mboxy2[254];
  167. int mboxx1[254];
  168. int mboxy1[254];
  169.  
  170.  
  171. /**************************************************************************/
  172. /* Function:    nada()                              */
  173. /* Description: Null drawing function used as the default.          */
  174. /**************************************************************************/
  175. nada(){}
  176.  
  177.  
  178.  
  179. /**************************************************************************/
  180. /* Function:    poly_draw()                          */
  181. /* Description: Draws polygons                          */
  182. /* IN:  tmp_handle - handle of screen device - xor_handle or shandle      */
  183. /*      num        - number of points.                      */
  184. /* OUT: none                                  */
  185. /* GLOBALS:  xor_handle - screen handle in xor mode              */
  186. /*         shandle    - screen handle in replace mode              */
  187. /*         mhandle    - Preview Buffer handle                  */
  188. /*         pxyarray[] - Vertice coordinates arrive this way...      */
  189. /*           graph_flag - graphic image? - 0 = no, 1 = yes          */
  190. /*         write_flag - write white or write black mode          */
  191. /*              0 = write white, 1 = write black          */
  192. /*         pxy[]      - Vertice coordinates arrive this way          */
  193. /*         ptsarray[] - Data stored in data structure passed in array   */
  194. /**************************************************************************/
  195. poly_draw(tmp_handle,num)
  196. int tmp_handle;
  197. int num;
  198. {
  199.      register int i,cnt;
  200.      int tflag;
  201.      int perimeter;
  202.  
  203.      if(!num)
  204.      return;
  205.      if(tmp_handle == xor_handle)
  206.      v_pline(xor_handle,num,pxyarray);
  207.      else
  208.      {
  209.          if(graph_flag)
  210.      {
  211.         if(cur_primitive == OLINE)
  212.             handle_line(write_flag,mhandle);
  213.         else
  214.                 handle_atari(write_flag,mhandle);
  215.      }
  216.          else
  217.        handle_write(write_flag,mhandle);
  218.  
  219.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  220.          cnt = 0;
  221.      for(i=0;i<num;i++)
  222.          {
  223.          scrn2mu(pxy[cnt],pxy[cnt+1],&ptsarray[cnt],&ptsarray[cnt+1],0,tflag);
  224.      mutopage(ptsarray[cnt],ptsarray[cnt+1],
  225.             &pxyarray[cnt],&pxyarray[cnt+1],0);
  226.         cnt+=2;
  227.          }
  228.          mclip();
  229.          if(cur_primitive == OLINE)
  230.      {
  231.        v_pline(mhandle,num,pxyarray);
  232.        put_poly(3,num,write_flag);
  233.          }
  234.      else
  235.          {
  236.            v_fillarea(mhandle,num,pxyarray);
  237.            perimeter = glgrattr[2] & 0x8000;
  238.        if(perimeter && graph_flag)
  239.            {
  240.             handle_line(write_flag,mhandle);
  241.                 v_pline(mhandle,num,pxyarray);
  242.            }
  243.            put_poly(0,num,write_flag);
  244.      }
  245.      }
  246. }
  247.  
  248.  
  249.  
  250.  
  251. /**************************************************************************/
  252. /* Function:    ellipse_draw()                          */
  253. /* Description: 2 stage ellipse draw.                      */
  254. /*        1) arcs are drawn until position is planted.          */
  255. /*        2) ellipse drawn to screen and preview buffer             */
  256. /*        3) ellipse data saved to data structure              */
  257. /*           Data saved in GLOBAL  PTSARRAY[]              */
  258. /* IN:  tmp_handle - screen handle  REPLACE or XOR mode              */
  259. /* GLOBAL: write_flag - writing mode: 0 = write white, 1 = write black    */
  260. /*       ptsarray[] - data for data structures              */
  261. /*         pxyarray[] - used for data manipulation              */
  262. /*       pxy[]      - data arrives in this way              */
  263. /*       graph_flag - graphic image? 0 = no, 1 = yes              */
  264. /*       xor_handle - screen xor mode handle                  */
  265. /*       shandle    - screen replace mode handle              */
  266. /*       mhandle    - preview buffer handle                  */
  267. /**************************************************************************/
  268. ellipse_draw(tmp_handle)
  269. int tmp_handle;
  270. {
  271.     int tflag;
  272.     int perimeter;
  273.  
  274.     perimeter = glgrattr[2] & 0x8000;
  275.     pxyarray[2] = abs(pxy[0] - pxy[2]);
  276.     pxyarray[3] = abs(pxy[1] - pxy[3]);
  277.     
  278.     if(tmp_handle == xor_handle)
  279.             v_ellarc(tmp_handle,pxy[0],pxy[1],
  280.              pxyarray[2],pxyarray[3],0,3600);
  281.     else
  282.     {
  283.          if(graph_flag)
  284.         handle_atari(write_flag,mhandle);
  285.          else
  286.         handle_write(write_flag,mhandle);
  287.  
  288.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  289.          scrn2mu(pxy[0],pxy[1],&ptsarray[0],&ptsarray[1],0,tflag);
  290.      mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);        
  291.          scrn2mu(pxyarray[2],pxyarray[3],&ptsarray[2],&ptsarray[3],1,tflag);
  292.      mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  293.  
  294.          mclip();
  295.          v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  296.      if(perimeter && graph_flag)
  297.      {
  298.             handle_line(write_flag,mhandle);
  299.         v_ellarc(mhandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  300.      }
  301.      put_ellipse(write_flag);
  302.     }
  303. }
  304.  
  305.  
  306.  
  307. /**************************************************************************/
  308. /* Function:    circle_draw()                          */
  309. /* Description: Draws a circle.                          */
  310. /*        1) draws elliptical arcs until planted.              */
  311. /*        2) draws into preview buffer and onto the screen      */
  312. /*        3) Data saved to data structure in GLOBAL PTSARRAY[]      */
  313. /* IN:      tmp_handle   - screen handle   XOR or REPLACE              */
  314. /* GLOBAL: write_flag  - write mode - 0 = write white, 1 = write black..  */
  315. /*       ptsarray[]  - data saved to data structure this way...      */
  316. /*       pxy[]       - data arrives this way...              */
  317. /*       graph_flag  - graphic images? 0 = no, 1 = yes...          */
  318. /*       xor_handle  - screen xor mode handle                  */
  319. /*       shandle     - screen replace mode handle              */
  320. /*       mhandle     - preview buffer handle                  */
  321. /**************************************************************************/
  322. circle_draw(tmp_handle)
  323. {
  324.     int radius;
  325.     int tflag;
  326.     int perimeter;
  327.     int xradius,yradius,temp;
  328.  
  329.     perimeter = glgrattr[2] & 0x8000;    
  330.     xradius = abs(pxy[0] - pxy[2]);
  331.     yradius = abs(pxy[1] - pxy[3]);
  332.     radius = max(xradius,yradius);
  333.   
  334.     if(axdpi[zdevice] == aydpi[zdevice])
  335.               xradius = yradius = radius;
  336.     else
  337.     {
  338.       if(axdpi[zdevice] > aydpi[zdevice])
  339.       {
  340.           temp = scaler(yradius,axdpi[zdevice],aydpi[zdevice]);
  341.           if(xradius >= temp)
  342.       {
  343.                yradius = scaler(xradius,aydpi[zdevice],axdpi[zdevice]);
  344.            radius = xradius;        
  345.           }
  346.           else
  347.           {
  348.            xradius = temp;
  349.            radius = yradius;
  350.           }
  351.       } 
  352.       else
  353.       {
  354.         temp = scaler(yradius,axdpi[zdevice],aydpi[zdevice]);
  355.         if(xradius >= temp)
  356.         {
  357.              yradius = scaler(xradius,aydpi[zdevice],axdpi[zdevice]);
  358.          radius = xradius;
  359.         }
  360.         else
  361.         {
  362.       xradius = temp;
  363.           radius = yradius;
  364.         }
  365.       }
  366.     }
  367.  
  368.     if(tmp_handle == xor_handle)
  369.             v_ellarc(tmp_handle,pxy[0],pxy[1],xradius,yradius,0,3600);
  370.     else
  371.     {
  372.        if(graph_flag)
  373.         handle_atari(write_flag,mhandle);
  374.        else
  375.         handle_write(write_flag,mhandle);
  376.  
  377.        tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  378.        scrn2mu(pxy[0],pxy[1],&ptsarray[0],&ptsarray[1],0,tflag);
  379.        mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);        
  380.  
  381.        if(axdpi[zdevice] != aydpi[zdevice])
  382.        {
  383.           scrn2mu(xradius,yradius,&ptsarray[2],&ptsarray[3],1,tflag);
  384.           if(xradius >= yradius)
  385.           {
  386.         ptsarray[3] = scaler(ptsarray[2],1152,1296);
  387.           }
  388.           else
  389.           {
  390.         ptsarray[2] = scaler(ptsarray[3],1296,1152);       
  391.           }
  392.        }
  393.        else
  394.        {
  395.           scrn2mu(radius,radius,&ptsarray[2],&ptsarray[3],1,tflag);
  396.        }
  397.        mutopage(ptsarray[2],ptsarray[3],&xradius,&yradius,1);
  398.  
  399.        mclip();
  400.        v_ellipse(mhandle,pxy[0],pxy[1],xradius,yradius);
  401.        if(perimeter && graph_flag)
  402.        {
  403.           handle_line(write_flag,mhandle);
  404.           v_ellarc(mhandle,pxy[0],pxy[1],xradius,yradius,0,3600);
  405.        }
  406.        put_ellipse(write_flag);
  407.     }
  408. }
  409.  
  410.  
  411.  
  412. /**************************************************************************/
  413. /* Function:    box_draw()                          */
  414. /* Description: Draws a box.. but saved as a polygon...                */
  415. /*         1) drawn as v_plines until planted.              */
  416. /*        2) box drawn to screen and preview buffer.          */
  417. /*        3) polygon saved to data structure.              */
  418. /*           Data saved in GLOBAL PTSARRAY[]              */
  419. /* IN:    tmp_handle - screen handle in REPLACE or XOR mode          */
  420. /* OUT:   none                                  */
  421. /* GLOBAL:  write_flag - write mode: 0 - write white, 1 - write black.      */
  422. /*        pxyarray[] - Internal data manipulation              */
  423. /*        pxy[]      - Data arrives in this array              */
  424. /*        ptsarray[] - Data passed to data structures through this...   */
  425. /*          cur_primitive - current drawing primitive in RCS units      */
  426. /*        xor_handle - screen xor mode handle                  */
  427. /*        shandle    - screen replace handle                  */
  428. /*        mhandle    - preview buffer handle                  */
  429. /*                                          */
  430. /**************************************************************************/
  431. box_draw(tmp_handle)
  432. int tmp_handle;
  433. {
  434.     register int i;
  435.     int tflag;
  436.     int perimeter;
  437.     int temp;
  438.  
  439.     perimeter = glgrattr[2] & 0x8000;    
  440.  
  441.  
  442.  
  443.     if(tmp_handle == xor_handle)
  444.     {
  445.        pxyarray[0] = pxyarray[6] = pxyarray[8] = pxy[0];
  446.        pxyarray[1] = pxyarray[3] = pxyarray[9] = pxy[1];
  447.        pxyarray[2] = pxyarray[4] = pxy[2];
  448.        pxyarray[5] = pxyarray[7] = pxy[3];
  449.  
  450.        v_pline(tmp_handle,5,pxyarray);
  451.     }
  452.     else
  453.     {
  454.        if(pxy[2] < pxy[0])    /* swap if inverted... */
  455.        {
  456.      temp = pxy[2];
  457.      pxy[2] = pxy[0];
  458.      pxy[0] = temp;
  459.        }
  460.  
  461.        if(pxy[3] < pxy[1])
  462.        {
  463.          temp = pxy[3];
  464.          pxy[3] = pxy[1];
  465.          pxy[1] = temp;
  466.        }
  467.        pxyarray[0] = pxyarray[6] = pxyarray[8] = pxy[0];
  468.        pxyarray[1] = pxyarray[3] = pxyarray[9] = pxy[1];
  469.        pxyarray[2] = pxyarray[4] = pxy[2];
  470.        pxyarray[5] = pxyarray[7] = pxy[3];
  471.  
  472.        if(cur_primitive == OIMAGE)
  473.          write_atari(mhandle);
  474.        else
  475.        {
  476.        if(graph_flag)
  477.          handle_atari(write_flag,mhandle);
  478.            else
  479.          handle_write(write_flag,mhandle);
  480.        }
  481.  
  482.          tflag = (((curr_page%2)&&(view_size == PADJCNT))?(TRUE):(FALSE));
  483.        for(i=0;i<10;i+=2)
  484.        {
  485.          scrn2mu(pxyarray[i],pxyarray[i+1],&ptsarray[i],&ptsarray[i+1],0,tflag);
  486.          mutopage(ptsarray[i],ptsarray[i+1],&pxy[i],&pxy[i+1],0);    
  487.        }
  488.        mclip();
  489.        if(cur_primitive == ORBOX)
  490.        {
  491.         pxyarray[0] = pxy[0];
  492.         pxyarray[1] = pxy[1];
  493.         pxyarray[2] = pxy[4];
  494.         pxyarray[3] = pxy[5];
  495.         v_rfbox(mhandle,pxyarray);
  496.         if(perimeter && graph_flag)
  497.         {
  498.            handle_line(write_flag,mhandle);
  499.            v_rbox(mhandle,pxyarray);
  500.         }
  501.         put_poly(4,5,write_flag);
  502.         return;
  503.        }
  504.        else    
  505.        {
  506.          v_fillarea(mhandle,5,pxy);
  507.      if(perimeter && graph_flag)
  508.          {
  509.             if(cur_primitive == OIMAGE)
  510.         {
  511.            vsl_type(mhandle,1);
  512.            vsl_width(mhandle,1);
  513.         }
  514.         else
  515.            handle_line(write_flag,mhandle);
  516.         if(pxy[0] == pxy[8] &&
  517.            pxy[1] == pxy[9])
  518.            {
  519.               pxy[10]     = pxy[2];
  520.               pxy[11]     = pxy[3];
  521.               v_pline(mhandle,6,pxy);
  522.            }
  523.            else
  524.               v_pline(mhandle,5,pxy);
  525.      }
  526.        }
  527.        if(cur_primitive == OIMAGE)
  528.        {
  529.         remove_path(fbuffer);
  530.             put_image(fbuffer,cur_pic_type);
  531.        }
  532.        else
  533.             put_poly(0,5,write_flag);
  534.     }
  535.  
  536. }
  537.  
  538.  
  539.  
  540. /**************************************************************************/
  541. /* Function:    redraw_ellipse()                      */
  542. /* Description: Redraws ellipse and circle                  */
  543. /*        Depending upon the mode, draws either in black, or draws  */
  544. /*        in black with a filled text outline.              */
  545. /* IN: wflag   - writing mode   -  1 = write black 0 = write white      */
  546. /* OUT: none                                  */
  547. /* GLOBAL:   mode_flag  - solid or text fill                   */
  548. /*         PTSARRAY[] - contains coordinate data.              */
  549. /**************************************************************************/
  550. redraw_ellipse(wflag,g_flag)
  551. int wflag;
  552. int g_flag;
  553. {
  554.    int thandle;
  555.    int perimeter;
  556.  
  557.    perimeter = glgrattr[2] & 0x8000;
  558.    if(!mode_flag)
  559.    {
  560.        if(g_flag)
  561.                handle_atari(wflag,mhandle);
  562.        else
  563.            handle_write(wflag,mhandle);
  564.  
  565.        mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);
  566.        mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  567.        v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  568.        if(perimeter && g_flag)
  569.        {
  570.             handle_line(wflag,mhandle);
  571.         v_ellarc(mhandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  572.        }
  573.    }
  574.    else
  575.    {
  576.      if(g_flag)
  577.      {
  578.        if(print_flag)
  579.        {
  580.        thandle = phandle;
  581.            mutolas(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1]);
  582.            mutolas(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3]);
  583.        }
  584.        else
  585.        {
  586.        thandle = mhandle;
  587.            mutopage(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1],0);
  588.            mutopage(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3],1);
  589.        }
  590.        handle_atari(wflag,thandle);
  591.        v_ellipse(thandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  592.        if(perimeter)
  593.        {
  594.             handle_line(wflag,thandle);
  595.         v_ellarc(thandle,pxy[0],pxy[1],pxy[2],pxy[3],0,3600);
  596.        }
  597.      }
  598.      else
  599.      {
  600.        handle_write(wflag,mhandle);
  601.        mutomem(ptsarray[0],ptsarray[1],&pxy[0],&pxy[1]);
  602.        mutomem(ptsarray[2],ptsarray[3],&pxy[2],&pxy[3]);
  603.        v_ellipse(mhandle,pxy[0],pxy[1],pxy[2],pxy[3]);
  604.      }
  605.    }
  606. }
  607.  
  608.  
  609.  
  610.  
  611. /**************************************************************************/
  612. /* Function:    redraw_polygon()                      */
  613. /* Description:                               */
  614. /**************************************************************************/
  615. redraw_polygon(count,wflag,g_flag)
  616. int count;
  617. int wflag;
  618. int g_flag;
  619. {
  620.    int thandle;
  621.    register int i;
  622.    register int cnt;
  623.    int perimeter;
  624.    int index;
  625.  
  626.    perimeter = glgrattr[2] & 0x8000;
  627.  
  628.    if(!count)
  629.     return;
  630.    if(!mode_flag)
  631.    {
  632.  
  633.        for(i=0;i<(count*2); i += 2)
  634.       mutopage(ptsarray[i],ptsarray[i+1],&pxy[i],&pxy[i+1],0);
  635.  
  636.        if(opcode == 3)
  637.        {
  638.         handle_line(wflag,mhandle);
  639.         v_pline(mhandle,count,pxy);
  640.        }
  641.        else
  642.        {
  643.                if(g_flag)
  644.                      handle_atari(wflag,mhandle);
  645.                 else
  646.                  handle_write(wflag,mhandle);
  647.      
  648.  
  649.         if(opcode == 4)
  650.         {
  651.            pxyarray[0] = pxy[0];
  652.            pxyarray[1] = pxy[1];
  653.            pxyarray[2] = pxy[4];
  654.            pxyarray[3] = pxy[5];
  655.            v_rfbox(mhandle,pxyarray);
  656.            if(perimeter && g_flag)
  657.            {
  658.                 handle_line(write_flag,mhandle);
  659.             v_rbox(mhandle,pxyarray);
  660.            }
  661.         }
  662.         else
  663.             {
  664.                   v_fillarea(mhandle,count,pxy);
  665.                if(perimeter && g_flag)
  666.                    {
  667.                       if(cur_primitive == OIMAGE)
  668.                   {
  669.                      vsl_type(mhandle,1);
  670.                      vsl_width(mhandle,1);
  671.                   }
  672.                   else
  673.                      handle_line(write_flag,mhandle);
  674.               index = count * 2;
  675.               if(pxy[0] == pxy[index - 2] &&
  676.                  pxy[1] == pxy[index - 1])
  677.               {
  678.                  pxy[index]     = pxy[2];
  679.                  pxy[index + 1] = pxy[3];
  680.                  v_pline(mhandle,count+1,pxy);
  681.               }
  682.               else
  683.                  v_pline(mhandle,count,pxy);
  684.                    }
  685.         }
  686.        }
  687.    }
  688.    else
  689.    {
  690.      if(g_flag)
  691.      {
  692.     cnt = 0;
  693.         if(print_flag)
  694.         {
  695.       thandle = phandle;
  696.       for(i=0;i<count;i++)
  697.           {
  698.        mutolas(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1]);
  699.        cnt+= 2;
  700.           }
  701.  
  702.         }
  703.         else
  704.         {
  705.       thandle = mhandle;
  706.       for(i=0;i<count;i++)
  707.           {
  708.        mutopage(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1],0);
  709.        cnt+= 2;
  710.           }
  711.  
  712.         }
  713.  
  714.     
  715.     if(opcode == 3)
  716.     {
  717.          handle_line(wflag,thandle);
  718.          v_pline(thandle,count,pxy);
  719.     }
  720.     else
  721.     {
  722.              handle_atari(wflag,thandle);
  723.          if(opcode == 4)
  724.          {
  725.            pxyarray[0] = pxy[0];
  726.            pxyarray[1] = pxy[1];
  727.            pxyarray[2] = pxy[4];
  728.            pxyarray[3] = pxy[5];
  729.            v_rfbox(thandle,pxyarray);
  730.                if(perimeter)
  731.                    {
  732.               handle_line(write_flag,thandle);
  733.               v_rbox(thandle,pxyarray);
  734.                    }
  735.          }
  736.          else
  737.          {
  738.             v_fillarea(thandle,count,pxy);
  739.             if(perimeter)
  740.                 {
  741.               index = count * 2;
  742.                   handle_line(write_flag,thandle);
  743.               if(pxy[0] == pxy[index - 2] &&
  744.                  pxy[1] == pxy[index - 1])
  745.               {
  746.                  pxy[index]     = pxy[2];
  747.                  pxy[index + 1] = pxy[3];
  748.                  v_pline(thandle,count+1,pxy);
  749.               }
  750.               else
  751.                  v_pline(thandle,count,pxy);
  752.                 }
  753.          }
  754.     }
  755.      }
  756.      else
  757.      {
  758.         handle_write(wflag,mhandle);
  759.         cnt = 0;
  760.     for(i=0;i<count;i++)
  761.         {
  762.        mutomem(ptsarray[cnt],ptsarray[cnt+1],&pxy[cnt],&pxy[cnt+1]);
  763.        cnt+= 2;
  764.         }
  765.     v_fillarea(mhandle,count,pxy);
  766.      }
  767.    }
  768. }
  769.  
  770.  
  771.  
  772. /**************************************************************************/
  773. /* Function:    do_handjreg()                          */
  774. /* Description: Scans the graphic mask in the scan buffer and returns       */
  775. /*        rectangle coordinates.                      */
  776. /* IN:                                        */
  777. /*        txtptr - ptr to text                      */
  778. /*        dflag  - done flag                          */ 
  779. /* OUT: none                                  */
  780. /* GLOBAL:  regx1,regx2,regy1,regy2 - rectangular area of region      */
  781. /*        jim_ptr  - data structure MFDB                   */
  782. /*          scanner() - performs actual scanning of mask.          */
  783. /*        sx1,sx2,sy1,sy2 - rectangle to draw.              */
  784. /**************************************************************************/
  785. extern struct txtattr cp;                  /* using GOG structure */
  786.  
  787. char *do_handjreg(txtptr,dflag,mode,rect_in_mu)
  788. char *txtptr;
  789. int  *dflag;
  790. int  mode;
  791. int  rect_in_mu[];
  792. {
  793.     int  tmp_handle;
  794.     int ptsin1[25];
  795.     int x1,y1,x2,y2;
  796.     int  sx1,sx2,sy1,sy2;
  797.     int  save_sx1;
  798.     FDB  *fdb_ptr;
  799.     int tmppage;
  800.     int muy;
  801.     long line_space;
  802.     int scanoff;
  803.     int dummy;
  804.  
  805.     *dflag = 0;
  806.     line_space = gltxtattr.lnsp;
  807.     tmppage = curr_page;
  808.     if(view_size == PADJCNT)
  809.     {
  810.     curr_page = curregion->p;
  811.     }
  812.     
  813.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  814.     cp.depth = cp.lnsp;
  815.     tmp_handle = shandle;
  816.  
  817.     if(mode == 3)
  818.         resetIFpos();
  819.  
  820.     mutomem(rect_in_mu[0],rect_in_mu[1],&sx1,&sy1);
  821.     mutomem(rect_in_mu[2],rect_in_mu[3],&sx2,&sy2);
  822.  
  823.     muy = rect_in_mu[1];
  824.     muy = max(muy,0);
  825.     if(cp.scoff)
  826.     {
  827.        if(muy + cp.scoff < rect_in_mu[3] )
  828.        {
  829.           muy += cp.scoff;              /* offset into scanner */
  830.       mutomem(muy,muy,&scanoff,&sy1);
  831.        }
  832.     }
  833.  
  834.     jim_ptr.BASE    = scanptr;
  835.     jim_ptr.FORM_WD = ((scan_xres + 15)/16)*2;
  836.     jim_ptr.FORM_HT = scan_yres;
  837.     sx1 = max(sx1,0);
  838.     save_sx1 = sx1;
  839.     sy1 = max(sy1,0);
  840.     sx2 = min(sx2,scan_xres);
  841.     sy2 = min(sy2,scan_yres);
  842.     jim_ptr.B_XMIN  = sx1;
  843.     jim_ptr.B_YMIN  = sy1;
  844.     jim_ptr.B_XMAX  = sx2;
  845.     jim_ptr.B_YMAX  = sy2;
  846.  
  847.     gltext.State = 0;
  848.     gltext.slvlist = 0L;
  849.  
  850.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  851.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  852.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  853.     ptsin1[9] = tmp_handle;
  854.  
  855.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  856.  
  857.     SX = sx1;
  858.     SY = sy1;
  859.     cpabt = 0;
  860.     tmpptr = endptr = txtptr;
  861.     while(scanner(&jim_ptr,SX,SY,SH,&sx1,&sy1,&sx2))
  862.     {
  863.        if(sy1 != SY)
  864.        {
  865.       if(sy1 == SY + SH)            /* Drop down a line */
  866.          muy += line_space - 1;
  867.       else
  868.          memtomu(dummy,sy1,&dummy,&muy);
  869.        }
  870.        if(sx2 == SX - 1 && sy1 == SY)
  871.        {
  872.       muy += line_space - 1;
  873.       SY += SH;        /* Rectangle hasn't moved */
  874.       SX = save_sx1;    /* Set to beginning of next line */
  875.        }
  876.        else
  877.        {
  878.           SX     = sx2 + 1;
  879.           SY     = sy1;
  880.        }
  881.        sy2    = sy1 + SH;
  882.  
  883.        if(muy + line_space - 1 > rect_in_mu[3])
  884.            break;
  885.  
  886.        memtomu(sx1,sy1,&x1,&y1);
  887.        memtomu(sx2,sy2,&x2,&y2);
  888.        
  889.        ptsin1[0] = x1;
  890.        ptsin1[3] = x2;
  891.  
  892.        cp.llen = x2 - x1 + 1;
  893. /*
  894.        cp.depth = (long)(y2 - y1 + 1);
  895.        cp.lnsp = cp.depth; 
  896. */
  897.        ptsin1[1] = ptsin1[4] = 0;
  898.        ptsin1[2] =  y1 = muy;
  899.        ptsin1[5] = y2 = muy + line_space - 1;
  900.        
  901.  
  902.        gltext.begtext   = tmpptr;
  903.        gltext.slvlist = 0L;       
  904.  
  905.        endptr = dotext(&gltext,ptsin1,fdb_ptr,mode,dflag);
  906.        switch(cpabt)
  907.        {
  908.       case 0:
  909.               add_scaninfo(curregion,x1,y1,x2,y2,tmpptr,gltext.slvlist);
  910.         break;
  911.       case 4:
  912.         *dflag = 0;
  913.         endptr = tmpptr;
  914.           freeslvlist(gltext.slvlist);
  915.         break;
  916.       case 8:
  917.               add_scaninfo(curregion,x1,y1,x2,y2,tmpptr,gltext.slvlist);
  918.         *dflag = 0;
  919.         curr_page = tmppage;
  920.         return(endptr);
  921.         break;
  922.       case 1:
  923.       case 2:
  924.       case 3:
  925.       case 5:
  926.       case 6:
  927.       case 7:
  928.           do_txterr(cpabt);
  929.           *dflag = 1;
  930.           break;
  931.        }
  932.  
  933.        if(*dflag)                /* Done */
  934.          break;
  935.        tmpptr = endptr;       
  936.     }
  937.     curr_page = tmppage;    
  938.     return(endptr);
  939. }
  940.  
  941.  
  942.  
  943. /**************************************************************************/
  944. /*    do_regoutput                              */
  945. /**************************************************************************/
  946. do_regoutput(txtptr,dflag)
  947. char *txtptr;
  948. int  *dflag;
  949. {
  950.     int x1,y1,x2,y2;
  951.     long tptr;
  952.     long slvptr;
  953.  
  954.     if(getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr))
  955.     {
  956.       if(slvptr)
  957.       do_output(dflag);
  958.       else
  959.       do_slvout(txtptr,dflag);
  960.     }
  961.     else
  962.       do_slvout(txtptr,dflag);
  963. }    
  964.  
  965.  
  966.  
  967. /**************************************************************************/
  968. /* Function:    do_slvout()                          */
  969. /**************************************************************************/
  970. do_slvout(txtptr,dflag)
  971. char *txtptr;
  972. int  *dflag;
  973. {
  974.     int  tmp_handle;
  975.     int ptsin1[25];
  976.     int x1,y1,x2,y2;
  977.     FDB  *fdb_ptr;
  978.     long *yptr;
  979.     long scanlist;
  980.     long tptr;
  981.     long slvptr;
  982.  
  983.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  984.     tmp_handle = shandle;
  985.  
  986.     resetIFpos();
  987.     gltext.State = 1;
  988.     
  989.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  990.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  991.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  992.     ptsin1[9] = tmp_handle;
  993.     ptsin1[10] = 0;
  994.  
  995.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  996.  
  997.     cpabt = 0;
  998.     tmpptr = txtptr;
  999.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1000.     while(scanlist)
  1001.     {
  1002.        ptsin1[0] = x1;
  1003.        ptsin1[3] = x2;
  1004.  
  1005.        cp.llen = x2 - x1 + 1;
  1006.        cp.depth = (long)(y2 - y1 + 1);
  1007.        cp.lnsp = cp.depth;
  1008.  
  1009.        yptr = (unsigned long *)(ptsin1 + 1);
  1010.        *yptr = (long)y1;
  1011.        yptr = (unsigned long *)(ptsin1 + 4);
  1012.        *yptr = (long)y2; 
  1013.  
  1014.        gltext.begtext   = tmpptr;
  1015.        gltext.slvlist = 0L;   
  1016.        endptr = dotext(&gltext,ptsin1,fdb_ptr,6,dflag);
  1017.  
  1018.        if(endptr == (char *)-1L)
  1019.        {
  1020.        if(cpabt == 4)        /* Line measure too short */
  1021.        {
  1022.         *dflag = 0;
  1023.         endptr = tmpptr;
  1024.        }
  1025.        else
  1026.        {
  1027.           do_txterr(cpabt);
  1028.           break;
  1029.           }
  1030.        }
  1031.        put_scaninfo(scanlist,gltext.slvlist);       
  1032.        if(*dflag)            /* Done or Output only mode */
  1033.          break;
  1034.        tmpptr = endptr;
  1035.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1036.     }
  1037.     
  1038.     if(print_flag) 
  1039.     write_black(mhandle);
  1040. }
  1041.  
  1042.  
  1043. /**************************************************************************/
  1044. /* Function:    do_slvout()                          */
  1045. /**************************************************************************/
  1046. do_slave_only(txtptr,dflag)
  1047. char *txtptr;
  1048. int  *dflag;
  1049. {
  1050.     int  tmp_handle;
  1051.     int ptsin1[25];
  1052.     int x1,y1,x2,y2;
  1053.     FDB  *fdb_ptr;
  1054.     long *yptr;
  1055.     long scanlist;
  1056.     long tptr;
  1057.     long slvptr;
  1058.  
  1059.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  1060.     tmp_handle = shandle;
  1061.  
  1062.     resetIFpos();
  1063.     gltext.State = 1;
  1064.     
  1065.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1066.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1067.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1068.     ptsin1[9] = tmp_handle;
  1069.     ptsin1[10] = 0;
  1070.  
  1071.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1072.  
  1073.     cpabt = 0;
  1074.     tmpptr = txtptr;
  1075.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1076.     while(scanlist)
  1077.     {
  1078.        ptsin1[0] = x1;
  1079.        ptsin1[3] = x2;
  1080.  
  1081.        cp.llen = x2 - x1 + 1;
  1082.        cp.depth = (long)(y2 - y1 + 1);
  1083.        cp.lnsp = cp.depth;
  1084.  
  1085.        yptr = (unsigned long *)(ptsin1 + 1);
  1086.        *yptr = (long)y1;
  1087.        yptr = (unsigned long *)(ptsin1 + 4);
  1088.        *yptr = (long)y2; 
  1089.  
  1090.        gltext.begtext   = tmpptr;
  1091.        gltext.slvlist = 0L;   
  1092.        endptr = dotext(&gltext,ptsin1,fdb_ptr,2,dflag);
  1093.  
  1094.        if(endptr == (char *)-1L)
  1095.        {
  1096.        if(cpabt == 4)        /* Line measure too short */
  1097.        {
  1098.         *dflag = 0;
  1099.         endptr = tmpptr;
  1100.        }
  1101.        else
  1102.        {
  1103.           do_txterr(cpabt);
  1104.           break;
  1105.           }
  1106.        }
  1107.        put_scaninfo(scanlist,gltext.slvlist);       
  1108.        if(*dflag)            /* Done or Output only mode */
  1109.          break;
  1110.        tmpptr = endptr;
  1111.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1112.     }
  1113. }
  1114.  
  1115. /**************************************************************************/
  1116. /* Function:    do_tdoout()                          */
  1117. /**************************************************************************/
  1118. do_tdoout(txtptr,dflag)
  1119. char *txtptr;
  1120. int  *dflag;
  1121. {
  1122.     int  tmp_handle;
  1123.     int ptsin1[25];
  1124.     int x1,y1,x2,y2;
  1125.     FDB  *fdb_ptr;
  1126.     long scanlist;
  1127.     long tptr;
  1128.     long slvptr;
  1129.  
  1130.     f_move(&gltxtattr,&cp,sizeof(cp));            /* GOG  */
  1131.     tmp_handle = shandle;
  1132.  
  1133.     topPge_TYF();
  1134.     gltext.State = 1;
  1135.     
  1136.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1137.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1138.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1139.     ptsin1[9] = tmp_handle;
  1140.     ptsin1[10] = 0;
  1141.  
  1142.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1143.  
  1144.     cpabt = 0;
  1145.     tmpptr = txtptr;
  1146.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1147.     while(scanlist)
  1148.     {
  1149.        ptsin1[0] = x1;
  1150.        ptsin1[3] = x2;
  1151.  
  1152.        cp.llen = x2 - x1 + 1;
  1153.        cp.depth = (long)(y2 - y1 + 1);
  1154.        cp.lnsp = cp.depth;
  1155.  
  1156.        ptsin1[2] = y1;
  1157.        ptsin1[5] = y2;
  1158.        ptsin1[1] = ptsin1[4] = 0;
  1159.  
  1160.        gltext.begtext   = tmpptr;
  1161.        gltext.slvlist = 0L;   
  1162.        endptr = dotext(&gltext,ptsin1,fdb_ptr,2,dflag);
  1163.  
  1164.        if(endptr == (char *)-1L)
  1165.        {
  1166.        if(cpabt == 4)        /* Line measure too short */
  1167.        {
  1168.         *dflag = 0;
  1169.         endptr = tmpptr;
  1170.           freeslvlist(gltext.slvlist);
  1171.        }
  1172.        else
  1173.        {
  1174.           do_txterr(cpabt);
  1175.           break;
  1176.           }
  1177.        }
  1178.        writeslv(gltext.slvlist);       
  1179.        if(*dflag)            /* Done or Output only mode */
  1180.          break;
  1181.        tmpptr = endptr;
  1182.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&slvptr);
  1183.     }
  1184. }
  1185.  
  1186.  
  1187.  
  1188.  
  1189. /**************************************************************************/
  1190. /* Function:    do_output()                          */
  1191. /**************************************************************************/
  1192. do_output(dflag)
  1193. int  *dflag;
  1194. {
  1195.     int  tmp_handle;
  1196.     int ptsin1[25];
  1197.     int x1,y1,x2,y2;
  1198.     FDB  *fdb_ptr;
  1199.     long scanlist;
  1200.     long tptr;
  1201.  
  1202.     tmp_handle = shandle;
  1203.     
  1204.     resetIFpos();
  1205.     gltext.State = 3;
  1206.  
  1207.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1208.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1209.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1210.     ptsin1[9] = tmp_handle;
  1211.     ptsin1[10] = 0;        /* No clipping */
  1212.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1213.  
  1214.     cpabt = 0;
  1215.  
  1216.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1217.     while(scanlist)
  1218.     {
  1219.        if(gltext.slvlist)
  1220.        {
  1221.           endptr = dotext(&gltext,ptsin1,fdb_ptr,4,dflag);
  1222.  
  1223.           if(endptr == (char *)-1L)
  1224.           {
  1225.           if(cpabt == 4)        /* Line measure too short */
  1226.           {
  1227.          *dflag = 0;
  1228.           }
  1229.           else
  1230.           {
  1231.              do_txterr(cpabt);
  1232.              break;
  1233.              }
  1234.       }
  1235.        }
  1236.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1237.     }
  1238.     
  1239.     if(print_flag) 
  1240.     write_black(mhandle);
  1241. }
  1242.  
  1243.  
  1244.  
  1245.  
  1246. /**************************************************************************/
  1247. /* Function:    do_clipregout()                          */
  1248. /**************************************************************************/
  1249. do_clipregout(clx1,cly1,clx2,cly2)
  1250. int clx1,cly1,clx2,cly2;
  1251. {
  1252.     int  tmp_handle;
  1253.     int ptsin1[25];
  1254.     int x1,y1,x2,y2;
  1255.     FDB  *fdb_ptr;
  1256.     long scanlist;
  1257.     long tptr;
  1258.     int dflag;
  1259.     int rx1,ry1,rx2,ry2;
  1260.     int pos_not_set;
  1261.     int rx[4];
  1262.     int sx[4];
  1263.     int oldy, offset_y;
  1264.     oldy = 0;
  1265.     tmp_handle = shandle;
  1266.     
  1267.     resetIFpos();
  1268.     gltext.State = 3;
  1269.  
  1270.     ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1271.     ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1272.     ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1273.     ptsin1[9] = tmp_handle;
  1274.     ptsin1[10] = 1;        /*  clipping */
  1275.     ptsin1[11] = sx[0] = clx1;
  1276.     ptsin1[12] = sx[1] = cly1;
  1277.     ptsin1[13] = sx[2] = clx2 + 1;    /* 1 pixel off on clipping */
  1278.     ptsin1[14] = sx[3] = cly2 + 1;
  1279.  
  1280.     fdb_ptr = ((print_flag) ?(&laser_MFDB):(&page_MFDB));                 
  1281.  
  1282.     cpabt = 0;
  1283.  
  1284.  
  1285.     scanlist = getf_scaninfo(curregion,&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1286.     mutopage(x1,y1,&rx[0],&rx[1],0);
  1287.     mutopage(x2,y2,&rx[2],&rx[3],0);
  1288.     if(rect_intersect(rx,sx))
  1289.     {
  1290.     resetIFpos();
  1291.     pos_not_set = 0;
  1292.     }
  1293.     else
  1294.     pos_not_set = 1;
  1295.     while(scanlist)
  1296.     {
  1297.        if(gltext.slvlist)
  1298.        { 
  1299.           if(oldy != y1)        /* Need to add line space to all */
  1300.       {                /* scanrects that don't have     */
  1301.              oldy = offset_y = y1;    /* positioning info in them      */
  1302.                      /* i.e. a scan directly to the   */
  1303.       }                /* right and parallel with another */
  1304.       else                /* scan                   */
  1305.       {
  1306.                 offset_y = y1 + curregion->text.lnsp - 1;
  1307.         pos_not_set = 1;
  1308.       }
  1309.           mutopage(x1,y1,&rx[0],&rx[1],0);
  1310.           mutopage(x2,y2,&rx[2],&rx[3],0);
  1311.           if(rect_intersect(rx,sx))        /* if the scan overlaps the clip*/
  1312.           {
  1313.          if(pos_not_set)
  1314.          {
  1315.         setYpos(offset_y);
  1316.         pos_not_set = 0;
  1317.          }
  1318.              endptr = dotext(&gltext,ptsin1,fdb_ptr,4,&dflag);
  1319.              if(endptr == (char *)-1L)
  1320.              {
  1321.                 if(cpabt == 4)        /* Line measure too short */
  1322.             {
  1323.           dflag = 0;
  1324.             }
  1325.             else
  1326.             {
  1327.                do_txterr(cpabt);
  1328.                break;
  1329.                }
  1330.              }
  1331.       }
  1332.        }
  1333.        scanlist = getn_scaninfo(&x1,&y1,&x2,&y2,&tptr,&gltext.slvlist);
  1334.     }
  1335.     
  1336.     if(print_flag) 
  1337.     write_black(mhandle);
  1338. }
  1339.  
  1340.  
  1341.  
  1342. /**************************************************************************/
  1343. /* Function:    do_outer()                          */
  1344. /* Description:                                  */
  1345. /**************************************************************************/
  1346. do_outer(handle,pxy)
  1347. int handle;
  1348. register int pxy[];
  1349. {
  1350.    int txy[10];
  1351.  
  1352.    txy[0] = pxy[0] - 5;txy[1] = pxy[1] - 5;
  1353.    txy[2] = pxy[2] + 5;txy[3] = pxy[3] + 5;
  1354.    do_box(handle,txy[0],txy[1],txy[2],txy[3]);
  1355. }
  1356.  
  1357.  
  1358.  
  1359. do_outline(handle,pxy)
  1360. int handle;
  1361. register int pxy[];
  1362. {
  1363.    int midx,midy;
  1364.    int txy[10];
  1365.    register int i;
  1366.      
  1367.       txy[0] = pxy[0] - 5;txy[1] = pxy[1] - 5;
  1368.       txy[2] = pxy[2] + 5;txy[3] = pxy[3] + 5;
  1369.       do_box(handle,txy[0],txy[1],txy[2],txy[3]);
  1370.  
  1371.       if(active_prim)
  1372.       {
  1373.     midx = (txy[0] + txy[2])/2;
  1374.     midy = (txy[1] + txy[3])/2;
  1375.  
  1376.  
  1377.     mboxx1[1] = mboxx1[5] = midx;
  1378.     mboxy1[0] = mboxy1[1] = mboxy1[2] = txy[1];
  1379.  
  1380.     mboxx1[2] = mboxx1[3] = mboxx1[4] = txy[2];
  1381.     mboxy1[3] = mboxy1[7] = midy;
  1382.  
  1383.     mboxy1[4] = mboxy1[5] = mboxy1[6] = txy[3];
  1384.  
  1385.     mboxx1[0] = mboxx1[6] = mboxx1[7] = txy[0];
  1386.  
  1387.  
  1388.     for(i=0;i<=8;i++)
  1389.         do_diamond(handle,mboxx1[i],mboxy1[i]);
  1390.       }
  1391.  
  1392.        mboxx1[0] = mboxx1[6] = mboxx1[7] = txy[0] - 3;
  1393.        mboxx2[0] = mboxx2[6] = mboxx2[7] = txy[0] + 3;
  1394.        mboxx1[2] = mboxx1[3] = mboxx1[4] = txy[2] - 3;
  1395.        mboxx2[2] = mboxx2[3] = mboxx2[4] = txy[2] + 3;
  1396.        mboxy1[0] = mboxy1[1] = mboxy1[2] = txy[1] - 3;
  1397.        mboxy2[0] = mboxy2[1] = mboxy2[2] = txy[1] + 3;
  1398.        mboxy1[4] = mboxy1[5] = mboxy1[6] = txy[3] - 3;
  1399.        mboxy2[4] = mboxy2[5] = mboxy2[6] = txy[3] + 3;
  1400.        midx = (txy[0] + txy[2])/2;
  1401.        midy = (txy[1] + txy[3])/2;
  1402.        mboxx1[1] = mboxx1[5] = midx - 3;
  1403.        mboxx2[1] = mboxx2[5] = midx + 3;
  1404.  
  1405.        mboxy1[3] = mboxy1[7] = midy - 3;
  1406.        mboxy2[3] = mboxy2[7] = midy + 3;
  1407.       
  1408.       if(!active_prim)
  1409.       {
  1410.         for(i=0;i<8;i++)
  1411.            do_box(handle,mboxx1[i],mboxy1[i],mboxx2[i],mboxy2[i]);
  1412.       }
  1413.       
  1414. }
  1415.  
  1416.  
  1417.  
  1418. do_diamond(handle,x1,y1)
  1419. int handle;
  1420. int x1,y1;
  1421. {
  1422.     pxyarray[0] = pxyarray[8] = x1-5;
  1423.     pxyarray[1] = pxyarray[9] = pxyarray[5] = y1;
  1424.  
  1425.     pxyarray[2] = pxyarray[6] = x1;
  1426.     pxyarray[3] = y1 - 5;
  1427.  
  1428.     pxyarray[4] = x1 + 5;
  1429.     pxyarray[7] = y1 + 5;
  1430.     v_pline(handle,5,pxyarray);
  1431. }
  1432.  
  1433.  
  1434.  
  1435.  
  1436. /**************************************************************************/
  1437. /* Function:    do_box()                          */
  1438. /* Description: Called by do_scan to draw the rectangle bar into the      */
  1439. /*        workstation buffer designated by handle...          */
  1440. /**************************************************************************/
  1441. do_box(handle,x1,y1,x2,y2)
  1442. int handle;
  1443. int x1,y1,x2,y2;
  1444. {
  1445.     pxyarray[0] = pxyarray[6] = pxyarray[8] = x1;
  1446.     pxyarray[1] = pxyarray[3] = pxyarray[9] = y1;
  1447.     pxyarray[2] = pxyarray[4] = x2;
  1448.     pxyarray[5] = pxyarray[7] = y2;
  1449.     v_pline(handle,5,pxyarray);
  1450. }
  1451.  
  1452.  
  1453.  
  1454. /**************************************************************************/
  1455. /* Function:    write_black()                          */
  1456. /* Description: switches fill style for writing to solid black.          */
  1457. /**************************************************************************/
  1458. write_black(handle)
  1459. int handle;
  1460. {
  1461.    vsf_interior(handle,1);
  1462.    vsf_perimeter(handle,FALSE);
  1463. }
  1464.  
  1465.  
  1466.  
  1467. /**************************************************************************/
  1468. /* Function:    write_white()                          */
  1469. /* Description: Changes device fill style to write in white.          */
  1470. /**************************************************************************/
  1471. write_white(handle)
  1472. int handle;
  1473. {
  1474.    vsf_interior(handle,0);
  1475.    vsf_perimeter(handle,FALSE);
  1476. }
  1477.  
  1478.  
  1479.  
  1480. /**************************************************************************/
  1481. /* Function:    write_atari()                          */
  1482. /* Description:                                  */
  1483. /**************************************************************************/
  1484. write_atari(handle)
  1485. int handle;
  1486. {
  1487. int curindex;
  1488. int curstyle;
  1489.  
  1490.      if((cur_primitive == OIMAGE) || (opcode == 2))
  1491.      {
  1492.         vsf_interior(handle,4);
  1493.      }
  1494.      else
  1495.      {
  1496.     curstyle = glgrattr[2] & 0x7fff;
  1497.     curindex = glgrattr[3];
  1498.     if(curstyle == 2)
  1499.     {
  1500.            if(curindex >= maxpat)
  1501.           curstyle = 0;                /* Hollow    */
  1502.     }
  1503.         vsf_interior(handle,curstyle);
  1504.         vsf_style(handle,curindex);
  1505.      }
  1506.      vsf_perimeter(handle,0);        /* handle perimeter ourselves   */
  1507. }
  1508.  
  1509.  
  1510.  
  1511. /**************************************************************************/
  1512. /* Function:    handle_atari()                          */
  1513. /* Description:                                  */
  1514. /**************************************************************************/
  1515. handle_atari(wflag,handle)
  1516. int wflag;
  1517. int handle;
  1518. {
  1519.      if(wflag)
  1520.            write_atari(handle);
  1521.      else 
  1522.        write_white(handle);
  1523. }
  1524.  
  1525.  
  1526.  
  1527. /**************************************************************************/
  1528. /* Function:    handle_write()                          */
  1529. /* Description:                                  */
  1530. /**************************************************************************/
  1531. handle_write(wflag,handle)
  1532. int wflag;
  1533. int handle;
  1534. {
  1535.        if(wflag)
  1536.        write_black(handle);
  1537.        else
  1538.        write_white(handle);
  1539. }
  1540.  
  1541.  
  1542.  
  1543. handle_line(wflag,handle)
  1544. int wflag;
  1545. int handle;
  1546. {
  1547.         int tmpwidth;
  1548.     int dummy;
  1549.         int mu_width;
  1550.  
  1551.     if(wflag)
  1552.         vsl_color(handle,TRUE);
  1553.     else
  1554.         vsl_color(handle,FALSE);
  1555.     if(glgrattr[1])            /* If line width in points... */
  1556.         vsl_type(handle,1);        /* Set style to solid        */
  1557.     else                /* Else single line so use pattern */
  1558.        vsl_type(handle,glgrattr[0]);
  1559.         if(!glgrattr[1])            /* line width of 1 */
  1560.        tmpwidth = 1;
  1561.         else
  1562.     {
  1563.        mu_width = pttomu(glgrattr[1]);
  1564.        if(handle == phandle)
  1565.           mutolas(dummy,mu_width,&dummy,&tmpwidth);
  1566.        else
  1567.           mutopage(dummy,mu_width,&dummy,&tmpwidth,1);
  1568.         }
  1569.     vsl_width(handle,tmpwidth);
  1570. }
  1571.  
  1572.  
  1573.  
  1574. /***********************************************************************/
  1575. /* Function: do_numbers()                           */
  1576. /* Description: Print actual page numbers...                   */
  1577. /***********************************************************************/
  1578. do_numbers(rgrect,tdo_flag)
  1579. int rgrect[];
  1580. int tdo_flag;
  1581. {
  1582.    long *yptr;
  1583.    FDB *fdbptr;
  1584.    int dflag;
  1585.    register int i,j;
  1586.    int size;
  1587.    int ptype;
  1588.    int y1,y2;
  1589.    int vbase;
  1590.    int ptsin1[25];
  1591.    char str[4];
  1592.    char text[PTEXTMAX];
  1593.    int just;
  1594.    int tgrect[4];
  1595.    int tpxy[4];
  1596.  
  1597.  
  1598.    if(pnum.display && pnum.text[0] && !tmplate_flag)
  1599.    {            /* display on and text exists and not template mode */
  1600.  
  1601.      ptype = ((curr_page%2)?(1):(0));
  1602.  
  1603.      if((pnum.usage == 0) && ptype)
  1604.             return;
  1605.      if((pnum.usage == 1) && !ptype)
  1606.             return;
  1607.  
  1608.      if((curr_page < pnum.fpage) || (curr_page > pnum.tpage))
  1609.                     return;
  1610.  
  1611.      just = ((ptype)?(pnum.rjust):(pnum.ljust));
  1612.      switch(just)
  1613.      {
  1614.       case 0: pnum.tattrib.jstmd = 1;    /* quad left  */
  1615.           break;
  1616.       case 1: pnum.tattrib.jstmd = 3;    /* quad center*/
  1617.           break;
  1618.       case 2: pnum.tattrib.jstmd = 2;    /* quad right */
  1619.           break;
  1620.      };
  1621.      f_move(&pnum.tattrib,&cp,sizeof(cp));
  1622.  
  1623.      if(tdo_flag)
  1624.     topPge_TYF();
  1625.      else
  1626.         resetIFpos();
  1627.  
  1628.      for(i=0;i<=4;i++)
  1629.        str[i] = 0x0;
  1630.      for(i=0;i<=PTEXTMAX;i++)
  1631.             text[i] = 0x0;
  1632.  
  1633.      itoa(curr_page,str);
  1634.      i=0;
  1635.      j=0;
  1636.      while((pnum.text[i]) && (i<=PTEXTMAX))
  1637.      {
  1638.     if(pnum.text[i] != '#')
  1639.         text[j++] = pnum.text[i];
  1640.         else
  1641.         {
  1642.        if(pnum.text[i+1] == '#')
  1643.        {
  1644.         text[j++] = pnum.text[i];
  1645.         i++;
  1646.        }
  1647.        j += strlen(str);
  1648.        if(j<=PTEXTMAX)
  1649.            strcat(text,str);
  1650.        else
  1651.          i=PTEXTMAX;
  1652.         }
  1653.     i++;
  1654.      }
  1655.  
  1656.      buf_start =  &text[0];
  1657.      buf_end   =  &text[PTEXTMAX];
  1658.  
  1659.      size = strlen(&text[0]);
  1660.      free_start = size + buf_start;
  1661.      current_char = buf_end;
  1662.  
  1663.  
  1664.      vbase = ((pnum.vpos)?(vpage_size):(0));    /* top or bottom? */
  1665.      y1 = ((vbase)?(vbase - pnum.distance):(pnum.distance));
  1666.      y2 = y1 + pttomu((pnum.pptsize / 8) + 5);
  1667.  
  1668.      if((print_flag) || (view_size != PADJCNT))
  1669.      {
  1670.         ptsin1[0] = 0;
  1671.         ptsin1[3] = hpage_size;
  1672.      }
  1673.      else
  1674.      {
  1675.     ptsin1[0] = ((curr_page % 2)?(hpage_size):(0));
  1676.     ptsin1[3] = ((curr_page % 2)?(2*hpage_size):(hpage_size));
  1677.      }
  1678.  
  1679.      if(rgrect)
  1680.      {
  1681.         mutopage(ptsin1[0],y1,&tpxy[0],&tpxy[1],0);
  1682.         mutopage(ptsin1[3],y2,&tpxy[2],&tpxy[3],0);
  1683.  
  1684.     tgrect[0] = tpxy[0];
  1685.         tgrect[1] = tpxy[1];
  1686.         tgrect[2] = tpxy[2] - tpxy[0] + 1;
  1687.         tgrect[3] = tpxy[3] - tpxy[1] + 1;
  1688.      }
  1689.  
  1690.      if(!rgrect || rc_intersect(rgrect,tgrect))
  1691.      {
  1692.        yptr = (unsigned long *)(ptsin1 + 1);
  1693.        *yptr = (long)y1;
  1694.        yptr = (unsigned long *)(ptsin1 + 4);
  1695.        *yptr = (long)y2;
  1696.  
  1697.  
  1698.        ptsin1[6] = ((print_flag) ? (axdpi[LASER]):(axdpi[PREVIEW]));
  1699.        ptsin1[7] = ((print_flag) ? (aydpi[LASER]):(aydpi[PREVIEW]));
  1700.        ptsin1[8] = ((print_flag) ? (100):(cur_scale));
  1701.        ptsin1[9] = shandle;
  1702.        ptsin1[10] = 0;                    /* no clip flag */
  1703.  
  1704.        fdbptr = ((print_flag) ? (&laser_MFDB) : (&page_MFDB));     
  1705.  
  1706.  
  1707.        gltext.State = 1;
  1708.        gltext.slvlist = 0L;
  1709.        gltext.begtext = buf_start;
  1710.  
  1711.        cp.llen = ptsin1[3] - ptsin1[0] + 1;
  1712.        cp.depth = (long)(y2 - y1 + 1);
  1713.        cp.lnsp = cp.depth;
  1714.        if(tdo_flag)
  1715.        {
  1716.      endptr = dotext(&gltext,ptsin1,fdbptr,2,&dflag);
  1717.      writeslv(gltext.slvlist);
  1718.        }
  1719.        else
  1720.          endptr = dotext(&gltext,ptsin1,fdbptr,6,&dflag);
  1721.      }
  1722.    }    /* pnum.display == FALSE */
  1723.  
  1724. }
  1725.